using System;
using System.Runtime.Remoting;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Be.Timvw.Framework.Tests.Remoting.RemotingHelper
{
    [TestClass]
    public class WhenGettingService
    {
        [TestMethod]
        public void ShouldReturnInstanceWhenWellKnownType()
        {
            RemotingConfiguration.RegisterWellKnownClientType(typeof(MyWellKnownType), "ipc://localhost/X");

            MyWellKnownType dummy = Be.Timvw.Framework.Remoting.RemotingHelper.GetService<MyWellKnownType>();
            Assert.IsNotNull(dummy);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void ShouldThrowWhenNotWellKnownType()
        {
            Be.Timvw.Framework.Remoting.RemotingHelper.GetService<MyNotWellKnownType>();
        }
    }
}